<?php
/* @var $this ContactController */
/* @var $model Contact */

$this->breadcrumbs=array(
	'Contacts'=>array('index'),
	'Manage',
);

?>

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'contact-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
        'afterAjaxUpdate'=>'reloadGrid',
	'columns'=>array(	
                array(
                    'header'=>'',
                    'value'=>'$this->grid->dataProvider->pagination->currentPage * $this->grid->dataProvider->pagination->pageSize + ($row+1)'
                ), 
		'userName',
                'email',		
                'companyName',
                'phone',
		'title',
                array(
                    'name'=>'status',
                    'value'=>'$data->status?"Da xem":"Chua xem"',
                    'filter' => array(1 => 'Da xem', 0 => 'Chua xem'),
                ),            
                array(
                    'name'=>'createTime',
                    'value'=>'date("Y-m-d H:i:s", $data->createTime)'
                ),
		array(
                    'class'=>'CButtonColumn',
                    'template'=>'{view} {delete}'
		),
	),
)); ?>

<script type="text/javascript">
    
    $(function(){
        $('.view').click(function(){
            $.ajax({
                url:$(this).attr('href'),
                success:function(data){
                    $.fancybox(data,{});//fancybox
                }
            });
            return false;
        });
    });
    
    function reloadGrid(id, data){
        $('.view').click(function(){
            $.ajax({
                url:$(this).attr('href'),
                success:function(data){
                    $.fancybox(data,{});//fancybox
                }
            });
            return false;
        });
    }
    
    function refreshGrid(){
        $.fn.yiiGridView.update('contact-grid');
    }
    
    function closeDialog(){
        $.fancybox.close();
    }
</script>